Please help me , with some errors .Code:#include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> #define MAX 50 char output[MAX]; char stack[MAX]; char input[MAX]; char *s,*t; char ch; int top; int l; int opr; void initialize(void); void SetExpression(char*); int PopFromStack(char); int priority(char); void ConvertToPrefix(void); void ConvertToPostfix(void); main (void) { initialize(); printf("\nEnter an expression in infix form:"); gets(input); printf("\nSpecify output expression type,1)Prefix 2)Postfix"); ch=getch(); SetExpression(input); if(ch=='1') { strrev(s); ConvertToPrefix(); strrev(output); printf("\nThe Prefix expression is:"); } else { ConvertToPostfix(); printf("\nThe Postfix expression is:"); } *(t)=opr; t++; opr= PopFromStack(); } PushOnStack((opr); PushOnStack((*(s)); } else PushOnStack(*(s)); s++; } if(*(s)=='(') { opr=PopFromStack(); while(opr!=')') { opr=PopFromStack(); } s++; } } while(top!=-1) { opr=PopFromStack(); *(t)=opr; t++; } t++; } char opr; while(*(s)) { if(*(s))==''||*(s)=='\t') { s++; continue; } if(isdigit(*(s))||isalpha(*(s))) { while(isdigit(*(s))||isalpha(* (s))) { *(t)=*(s); s++; t++; } } if(*(s)=='(') { PushOnStack(*(s)); s++; } if(*(s)=='*'||*(s)=='+'||*(s) =='/'||*(s)=='%'||*(s)=='-'||*(s) =='^') { if(top!=-1) { opr=PopFromStack(); while(priority(opr)>= priority(*(s))) { *(t)=opr; t++; opr= PopFromStack(); } PushOnStack(opr); PushOnStack(*(s)); } else PushOnStack(*(s)); s++; } if(*(s)==')') { opr=PopFromStack(); while(opr!='(') { *(t)=opr; t++; opr=PopFromStack(); } s++; } while(top!=-1) { opr=PopFromStack(); *(t)=opr(); t++; } t++; } getch(); }
http://i44.tinypic.com/11cfx28.png
my output should look like this ..
Enter an expression in infix form: (9+6)/(2*4)^15
Specify output epression type,1) Prefix 2)Postfix
The Prefix expression is: /+96^*2415
----------------------------------------------
Enter an expression in infix form: (9+6)/(2*4)^15
Specify output epression type,1) Prefix 2)Postfix
The Postfix expression is:96+24*15^/